/**
 * Self define EXT Widgets for CRM
 */

// Remote data Combo box
Ext.define("Ext.crm.form.field.ComboBox", {
    extend: "Ext.form.field.ComboBox",
    alias: ["widget.uXcombo"],
    comboOpts: {
    },
    queryMode: 'remote',
    valueField: "value",
    displayField: "full_name",
    editable: false,

    // Override initComponent
    initComponent: function() {
    	// create a new store for this combo box
    	var me = this;
    	me.store = Ext.create("Ext.data.Store", {
    		fields: [
                 {name:"codeKey", type:"string"},
                 {name:"value", type:"string"},
                 {name:"full_name", type:"string"},
                 {name:"abbr_name", type:"string"},
                 {name:"disp_no", type:"int"}
             ],
             proxy: {
            	 type: "ajax",
            	 extraParams: me.comboOpts,
            	 url: "common/combo.shtm",
            	 reader: {
            		 root: "comboDataList"
            	 }
             }
    	});

    	// reset show type
    	if (me.comboOpts.showType == "abbr") {
    		me.displayField = "abbr_name";
    	}

    	// call super
        Ext.crm.form.field.ComboBox.superclass.initComponent.call(this);
    }
});

